<template>
  <Table :columns="columns" :data="data"></Table>
</template>

<script>
  import affixTime from "@/views/lili-components/affix-time";
  import * as API_Goods from "@/api/goods";
  import Cookies from "js-cookie";

  export default {
    components: { affixTime },
    data() {
      return {
        setting:"",
        params: { // 請求參數
          searchType: "LAST_SEVEN",
          year: "",
          month: "",
          storeId: JSON.parse(Cookies.get("userInfoSeller")).id || '',
          type: "NUM"
        },
        columns: [ // 表格表頭
          {
            title: "商品名稱",
            key: "goodsName",
          },
          {
            title: "销售數量",
            key: "num",
          },
          {
            title: "销售金额",
            key: "price",
            render: (h, params) => {
              return h("priceColorScheme", {props:{value:params.row.price,color:this.$mainColor}} );
            },
          },
        ],
        data: [], // 表格數据
      };
    },
    computed:{

    },
    methods: {
      // tab切换
      handleClickType(name) {
        this.params.type = name;
        this.getData();
      },
      // 時間筛選
      clickBreadcrumb(item, index) {
        let callback = item;
        let type = this.params.type;
        this.params = {...callback};
        this.params.type = type;
        this.getData();
      },
      // 获取數据
      getData() {
        Promise.all([API_Goods.goodsStatistics(this.params)]).then((res) => {
          if (res[0].result) {
            this.data = res[0].result;
          }
        });
      },
    },
    mounted() {
      this.getData();
    },
  };
</script>

<style scoped lang="scss">
.fixed-bottom{
  position:sticky;
  z-index: 999;
  top: 0;
}
.card {
  margin-bottom: 10px;
}
</style>
